import json

from flask import Flask, render_template, Response

app = Flask(__name__)
#方式一
# app.config['SECRET_KEY'] = '123@qwee'
# app.config['SQLALCHEMY_DATABASE_URI'] = ''
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False


@app.route('/')
def hello_world():  # put application's code here
    return 'Hello World!'
# def index():
#     name = 'hello'
#     return render_template('index.html', name=name)

# 方式二
# app.config.update(
#     MAIL_SERVER='smtp.qq.com',
#     MAIL_PORT=465,
#     MAIL_USE_SSL=True,
#     MAIL_USERNAME='',
#     MAIL_PASSWORD='',
#     MAIL_DEFAULT_SENDER=''
# )
# 
# # 方式三
# app.config.from_file('config.json', load=json.load())


@app.route('/hello1/<num>', methods=['GET'])
def hello_world(num):  # put application's code here
    return 'Hello World!' + num


@app.route('/index_resp')
def index_resp():
    # 使用Response类的构造方法生成响应对象，设置状态码为201，响应类型为text/html
    resp = Response(response='Python&Flask', status=201,
                        content_type='text/html;charset=utf-8')
    return resp


@app.route('/index')
def index():
    name = 'admin'
    return render_template('index.html', name=name)  # 渲染模板文件index.html
@app.route('/')
def index_1():
    return render_template('login.html')
@app.route('/login',methods=['POST'])
def dologin():
   return render_template('index.html')
@app.route('/user/list')
def user_index():
    name = 'hello'
    return render_template('index.html', name=name)  # 渲染模板文件index.html


@app.route('/dept/list')
def dept_index():
    name = 'hello'
    return render_template('index.html', name=name)

def dologin():
    param=request.form
    username=param.get('username')
    password=param.get('password')
    user = LoginService.login(username, password);
    if user



if __name__ == '__main__':
    app.run()